/*
 * SMSBulkMessage.java
 *
 * Created on February 5, 2005, 3:28 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package org.naga.bulksender.data;

import java.util.ArrayList;
import java.util.List;
import org.smslib.OutboundMessage;
import static org.naga.bulksender.constant.Constant.*;
/**
 *
 * @author nestor.carrasco
 */
public class SMSBulkMessage extends OutboundMessage implements BulkMessage {

    private Integer smsId;
    private List<String> numberManullyLst = null;
    private List<String> numberFromContactLst = null;
    private List<String> numberFromGroupLst = null; 
    private int totalReceipent = -1;

    /** Creates a new instance of SMSBulkMessage */
    public SMSBulkMessage(String text, Integer id) {
        this(text, id, null);
    }

    public SMSBulkMessage(String text, Integer id, List<String> lstManually) {
        super(GROUP_NAME + id, text);
        setId(id + "");
        numberManullyLst = lstManually;
        smsId = id;
    }

    public void setNumbers(List<String> numbersLst) {
        numberManullyLst = numbersLst;
    }

    public List<String> getNumbers() {
        if (numberManullyLst == null) {
            numberManullyLst = new ArrayList<String>();
        }
        return numberManullyLst;
    }

    public void setBulkSmsId(Integer id) {
        smsId = id;
    }

    public Integer getBulkSmsId() {
        return smsId;
    }

    public void setLstNumberFromContacts(List<String> numbersLst) {
        this.numberFromContactLst = numbersLst;
    }

    public List<String> getLstNumberFromContacts() {
        if (numberFromContactLst == null) {
            numberFromContactLst = new ArrayList<String>();
        }
        return numberFromContactLst;
    }

    public void setLstNumberFromGroups(List<String> numbersLst) {
        this.numberFromGroupLst = numbersLst;
    }

    public List<String> getLstNumberFromGroups() {
        if (numberFromGroupLst == null) {
            numberFromGroupLst = new ArrayList<String>();
        }
        return numberFromGroupLst;
    }

    public int getTotalReceipent() {
        if ( this.totalReceipent == -1 ){
            this.totalReceipent = getLstNumberFromContacts().size() +
                    getLstNumberFromGroups().size() +
                    getNumbers().size();
        }
        return this.totalReceipent;
    }

    public synchronized int decreaseSmsCounter() {
        return --this.totalReceipent;
    }
}